-
Notifications
You must be signed in to change notification settings - Fork 182
Fix LabelSelector validation markers for map field #1679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix LabelSelector validation markers for map field #1679
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: KillianGolds The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Welcome @KillianGolds! |
Hi @KillianGolds. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
893892d
to
b9b7a12
Compare
/cherry-pick release-1.0 |
b9b7a12
to
68f3f39
Compare
Changed MinItems/MaxItems to MinProperties/MaxProperties for the MatchLabels field in LabelSelector, as it is a map type, not an array. This resolves controller-gen CRD generation errors. Signed-off-by: Killian Golds <[email protected]>
68f3f39
to
40cecfd
Compare
…nifests Gateway API Inference Extension v1.0.0 has invalid kubebuilder validation markers (MinItems/MaxItems on a map field) causing controller-gen to fail. Applied temporary fork workaround pointing to personal fork based on v1.0.0 tag with the fix applied. Changes: - Add replace directive in go.mod for GIE fork at kserve-compatibility-v1.0 - Regenerate all CRD manifests with controller-gen v0.17.2 - Regenerate Go code (deepcopy, openapi) and Python SDK - Fix linting errors in scheduler.go The fork maintains K8s v0.33.4 compatibility (no version conflicts). This is a temporary workaround until upstream merges the fix and releases a patched version. Upstream issue: kubernetes-sigs/gateway-api-inference-extension#1678 Upstream fix PR: kubernetes-sigs/gateway-api-inference-extension#1679 rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
Add controller-gen crd to the generate target to validate kubebuilder markers during development and CI runs. Previously, make generate only ran controller-gen object, which generates DeepCopy methods but does not validate CRD markers like MinItems, MaxItems, MinProperties, etc. This meant invalid markers could be merged without detection, only to cause failures in downstream projects that run full CRD generation. By adding CRD generation to the generate target: - Invalid kubebuilder markers are caught immediately during development - CI will fail if markers are incorrect or CRDs are out of sync - Prevents downstream projects from encountering CRD generation errors - Aligns with the target's existing documentation which states it generates CustomResourceDefinition objects This change would have caught the MinItems/MaxItems issue fixed in commit 40cecfd before it was merged. Signed-off-by: Killian Golds <[email protected]>
/ok-to-test |
Thanks @KillianGolds! This feels like a good candidate for a patch release. /lgtm |
@KillianGolds: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
I think you need to regenerate crds for ci to pass. additionally, not sure why we need the changes in makefile. |
// +kubebuilder:validation:MinProperties=1 | ||
// +kubebuilder:validation:MaxProperties=64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing because you need to generate the CRDs after making changes to the Go types.
@KillianGolds we would like to include this in a patch release. When do you expect to resolve #1679 (comment)? |
Will be first priority tomorrow morning Irish time. Will be resolved within an hour ideally. Just converted to draft untill I address comments and fix crd's but its out of hours for me at the moment so will be done first thing in the morning. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR fixes a controller-gen CRD generation error and adds safeguards to prevent similar issues in the future.
Problem:
The
MatchLabels
field inLabelSelector
(api/v1/shared_types.go
) hadMinItems
andMaxItems
validation markers applied, but these markers are only valid for array types. SinceMatchLabels
is defined asmap[LabelKey]LabelValue
, controller-gen would fail with errors:must apply minitems to an array
must apply maxitem to an array
Impact:
This caused CRD generation failures for downstream projects (e.g., OpenDataHub KServe) that import Gateway API Inference Extension as a dependency and run
controller-gen crd
as part of their build process.Solution:
Commit 1: Fix the validation markers
Changed the validation markers in
api/v1/shared_types.go
from:+kubebuilder:validation:MinItems=1
→+kubebuilder:validation:MinProperties=1
+kubebuilder:validation:MaxItems=64
→+kubebuilder:validation:MaxProperties=64
MinProperties
andMaxProperties
are the correct validation markers for map types and enforce the same constraints (1-64 entries) on the map.Commit 2: Add CRD generation to
make generate
targetAdded
controller-gen crd
to the generate target to catch invalid kubebuilder markers during development and CI runs.Previously,
make generate
only rancontroller-gen object
, which generates DeepCopy methods but does not validate CRD markers. This meant invalid markers could be merged without detection.By adding CRD generation to the generate target:
make verify
)This change would have caught the MinItems/MaxItems issue before it was merged.
Why wasn't this caught upstream?
The upstream CI only runs
make generate
, which executescontroller-gen object
for generating DeepCopy methods. This command does not validate kubebuilder markers or generate CRDs (see controller-gen docs).The error surfaced downstream in projects that run full CRD generation with
controller-gen crd
, which validates all kubebuilder markers.Testing:
make manifests
minProperties: 1
,maxProperties: 64
)kubectl-validate
Which issue(s) this PR fixes:
Fixes #1678
Does this PR introduce a user-facing change?: